package io.gitee.pkmer.greet.plugin;

import io.gitee.pkmer.greet.config.AnotherGreetingPluginExtension;
import io.gitee.pkmer.greet.config.LombokGreetingPluginExtension;
import io.gitee.pkmer.greet.config.StringGreetingPluginExtension;
import io.gitee.pkmer.greet.config.GreetingPluginExtension;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.Task;
import org.gradle.api.tasks.TaskContainer;

/**
 * @author 胖卡
 * @version 1.0.0
 * @date 2024/8/12
 */
public abstract class GreetingPlugin implements Plugin<Project> {
    @Override
    public void apply(Project project) {
        GreetingPluginExtension greetingPluginExtension = project.getExtensions().create("greeting", GreetingPluginExtension.class);

        TaskContainer tasks = project.getTasks();
        Task hello = tasks.register("hello").get();
        hello.setDescription("Hello World");
        hello.setGroup("pkmer boot");

        hello.doLast( task -> {
//            System.out.println(greetingPluginExtension.message + " " + greetingPluginExtension.greeter);
            System.out.println(greetingPluginExtension.getMessage().get() + " " + greetingPluginExtension.getGreeter().get());
//            System.out.println(greetingPluginExtension.getMessage() + " " + greetingPluginExtension.getGreeter());
        });

    }
}
